function imagenMovimiento(url,ancho, alto, x, y,container, label) {
    this.url = url;
    this.ancho = ancho;
    this.alto = alto;
    this.label = label;
    this.container = container;
    this.ratonX = 0;
    this.ratonY = 0;
    this.stage = new createjs.Stage(container);
    this.circle = new createjs.Shape();
    this.circle.graphics.beginFill("red").drawCircle(0, 0, 50);
    this.circle.x = x;
    this.circle.y = y;
    this.stage.addChild(circle);
    createjs.Ticker.addEventListener("tick", tickHandler);
    createjs.Ticker.setFPS(60);
    this.stage.onMouseMove = function(){ratonX = event.pageX; ratonY = event.pageY;};
    this.stage.update();
}

function get(variable)
{
    switch(variable)
    {
        case "url":
            return this.url;
            break;
        case "ancho":
            return this.ancho;
            break;
        case "alto":
            return this.alto;
            break;
        case "x":
            return this.circle.x;
            break;
        case "y":
            return this.circle.y;
            break;
        default:
            return null;
            break;
    }
}

function set(variable, valor)
{
    switch(variable)
    {
        case "url":
            this.url = valor;
            break;
        case "ancho":
            this.ancho = valor;
            break;
        case "alto":
            this.alto = valor;
            break;
        case "x":
            this.circle.x = valor;
            break;
        case "y":
            this.circle.y = valor;
            break;
    }
}


function tickHandler(event)
{
    //Actualizamos el label con los datos para depurar
    document.getElementById(this.label).innerHTML = 'Coordenada X ratón: ' + this.ratonX + "<br/>Coordenada Y ratón: " + this.ratonY + '<br>';
    document.getElementById(this.label).innerHTML += 'Coordenada X pelota: ' + this.circle.x + "<br/>Coordenada Y pelota: " + this.circle.y + '<br>';
    if(this.circle.x > this.ratonX+25)
    {
        this.circle.x = this.circle.x - 15;
        document.getElementById(this.label).innerHTML += '<br/>x--';
    }else if(this.circle.x < this.ratonX-25)
    {
        this.circle.x = this.circle.x + 15;
        document.getElementById(this.label).innerHTML += '<br/>x++';
    }else if(this.circle.y > this.ratonY+25)
    {
        this.circle.y = this.circle.y - 15;
        document.getElementById(this.label).innerHTML += '<br/>y--';
    }else if(this.circle.y < this.ratonY-25)
    {
        this.circle.y = this.circle.y + 15;
        document.getElementById(this.label).innerHTML += '<br/>y++';
    }
    this.stage.update();
    
}